import mockApi from "@/api/mockApi";

export default class skillCertificateApi {
  static skillCertificates = [
    {"id":1,"candidateId":3,"candidateName":"张伟","certificateName":"PMP项目管理专业人士认证","issuingAuthority":"PMI（项目管理协会）","issueDate":"2020-05-15","expiryDate":"2023-05-15","createTime":"2024-02-27 22:24:15","modifyTime":"2024-03-23 22:24:15"},{"id":2,"candidateId":4,"candidateName":"陈静","certificateName":"Scrum Master认证","issuingAuthority":"Scrum Alliance","issueDate":"2019-08-10","expiryDate":"2022-08-10","createTime":"2024-10-04 22:24:15","modifyTime":"2024-07-21 22:24:15"},
    {"id":3,"candidateId":2,"candidateName":"陈静","certificateName":"AWS解决方案架构师认证","issuingAuthority":"亚马逊云科技（AWS）","issueDate":"2021-03-20","expiryDate":"2024-03-20","createTime":"2024-08-17 22:24:15","modifyTime":"2024-01-16 22:24:15"},
    {"id":4,"candidateId":3,"candidateName":"张伟","certificateName":"Oracle认证数据库专家","issuingAuthority":"Oracle公司","issueDate":"2018-11-01","expiryDate":"2021-11-01","createTime":"2024-02-07 22:24:15","modifyTime":"2024-06-28 22:24:15"},
    {"id":5,"candidateId":2,"candidateName":"陈静","certificateName":"Google数据分析师认证","issuingAuthority":"Google","issueDate":"2022-06-05","expiryDate":"2025-06-05","createTime":"2024-01-15 22:24:15","modifyTime":"2024-10-19 22:24:15"},
    {"id":6,"candidateId":1,"candidateName":"王强","certificateName":"Cisco认证网络工程师","issuingAuthority":"Cisco","issueDate":"2017-09-12","expiryDate":"2020-09-12","createTime":"2024-02-15 22:24:15","modifyTime":"2024-04-11 22:24:15"},
    {"id":7,"candidateId":3,"candidateName":"张伟","certificateName":"微软Azure解决方案架构师认证","issuingAuthority":"微软","issueDate":"2023-02-10","expiryDate":"2026-02-10","createTime":"2024-12-08 22:24:15","modifyTime":"2024-06-21 22:24:15"}
  ]

  static async save (params) {
    console.log('skillCertificateApi save params', params)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }

  static async find (params) {
    console.log('skillCertificateApi find params', params)
    let filteredSkillCertificates = skillCertificateApi.skillCertificates
    if (params.candidateId) {
      filteredSkillCertificates = skillCertificateApi.skillCertificates.filter(skillCertificate => skillCertificate.candidateId === params.candidateId);
    }
    const response = await mockApi.queryPageSuccessfully(filteredSkillCertificates)
    return response.data
  }

  static async findById (id) {
    console.log('skillCertificateApi findById id', id)
    let target = {}
    for (let a of skillCertificateApi.skillCertificates) {
      if (a.id === id) {
        target = a
      }
    }
    const response = await mockApi.queryByIdSuccessfully(target)
    return response.data
  }

  static async del (id) {
    console.log('skillCertificateApi del id', id)
    const response = await mockApi.operateSuccessfully()
    return response.data
  }
}